package com.lvkerry.orderfood.util

import java.time.LocalDate
import java.time.ZoneId
import java.time.format.DateTimeFormatter


/**
 * 生成唯一订单号
 */
fun generateOrderNumber(username: String = "none"): String {
    return "ABA-${getToday(LocalDate.now())}-$username"
}

fun getToday(date: LocalDate): String {
    return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
}


fun convertStringToTimeStamp(date: String): Long {
    val parse1 = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"))
    return (1000L * parse1.atStartOfDay(ZoneId.systemDefault()).toEpochSecond()).toLong()
}